def isValidSudoku(board: [[str]]) -> bool:
    pieces = [set() for _ in range(9)]
    cols = [set() for _ in range(9)]
    for i, row in enumerate(board):
        nums = set()
        for j, num in enumerate(row):
            if num != '.':
                r = i // 3
                c = j // 3
                idx = r * 3 + c
                if num in nums:
                    return False
                if num in cols[j]:
                    return False
                if num in pieces[idx]:
                    return False
                nums.add(num)
                pieces[idx].add(num)
                cols[j].add(num)
    return True


if __name__ == '__main__':
    print(isValidSudoku([["5","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
))
    print(isValidSudoku([["8","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
))
